<template>
  <view class="content">
    <view>
      <index :userInfo="userInfo"></index>
    </view>
    <view>
      <content :is_login="is_login"></content>
    </view>
  </view>
</template>

<script>
// 登录模块
import index from "@/components/mine/Index.vue";
import content from "@/components/mine/content.vue";

export default {
  name: "mine",
  components: {
    // 展示用户头像信息
    index,
    // 主要功能选项
    content,
  },
  data() {
    return {
      userInfo: {},
      is_login: false,
    };
  },
  onLoad() {
    console.log("index onLoad");
    this.getUserInfo();
  },
  methods: {
    update() {
      this.onReady();
    },
    async getUserInfo() {
      console.log("getUserInfo running-----------");
      // this.userInfo = uni.getStorageSync("userInfo");
      // this.userInfo = JSON.parse(this.userInfo);
      // if (uni.getStorageSync("userInfo")) {
      //   this.userInfo = await JSON.parse(uni.getStorageSync("userInfo"));
      // }
      uni.getStorage({
        key: "userInfo",
        success: (res) => {
          console.log(res);
          // this.userInfo = JSON.parse(res.data);
          console.log(res);
          this.userInfo = res.data;
          this.is_login = true;
        },
        fail: (err) => {
          console.log("错误信息：" + err);
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.content {
  height: 100vh;
  background-color: aliceblue;
}
</style>